package cn.wolfcode.web.controller;

import cn.wolfcode.domain.Business;
import cn.wolfcode.domain.SystemDictionaryItem;
import cn.wolfcode.service.IBusinessService;
import cn.wolfcode.service.ISystemDictionaryItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class IndexController {

    @Autowired
    private IBusinessService businessService;
    @Autowired
    private ISystemDictionaryItemService systemDictionaryItemService;

    @RequestMapping("/homepage")
    public String list(Model model) {
        Business business = businessService.selectMainStore();
        List<SystemDictionaryItem> dictionaryItems = systemDictionaryItemService.selectBySn("business");
        model.addAttribute("business", business);
        model.addAttribute("dictionaryItems", dictionaryItems);
        model.addAttribute("stores", businessService.listAll());

        return "index";
    }
}
